﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfPropertyService
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码和配置文件中的类名“Service1”。
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class BookService : IBookService
    {
        List<Book> _books = new List<Book>();
        public void AddBooks(Book book)
        {
            book.BookNo = Guid.NewGuid().ToString();
            _books.Add(book);
        }

        public List<Book> GetAllBooks()
        {
            return _books;
        }

        public void RemoveBook(string id)
        {
            Book book = _books.Find(p => p.BookNo == id);
            _books.Remove(book);
        }
    }
}
